object TestGenericScala {


  def main(args: Array[String]): Unit = {
    val h2 = new High2()
    val h = new High()
    val m = new Middle()
    val l = new Low()
    val l2 = new Low2()


    val r: High2 = down(h2)
    val high: High = down(h)
    val middle: Middle = down(m)
    val middle1: Middle = down(l)
    val middle2: Middle = down(l2)

    down[High](new Low)

    //val high1: High = upper(new High())
    val low: Low = upper[Low](new Low())

    val x = new X()

  }

  def down[T>:Middle](t:T): T ={t}
  def upper[T<:Middle](t:T): T ={t}
}


private class X[C]{


}

private class High2 {}

private class High extends High2 {}

private class Middle extends High {}

private class Low extends Middle {}

private class Low2 extends Low {}